"""
订单相关Schema
"""
from pydantic import BaseModel
from typing import List, Optional
from decimal import Decimal
from datetime import datetime


class OrderItemInput(BaseModel):
    goods_id: int
    name: str
    price: Decimal
    qty: int
    image_url: Optional[str] = None


class CreateOrderRequest(BaseModel):
    items: List[OrderItemInput]


class OrderItemResponse(BaseModel):
    goods_id: int
    name: str
    price: Decimal
    qty: int
    image_url: Optional[str] = None

    class Config:
        from_attributes = True


class OrderResponse(BaseModel):
    order_no: str
    total_amount: Decimal
    status: int
    created_at: datetime
    items: List[OrderItemResponse]

    class Config:
        from_attributes = True


